package client.comm.baoding.ui.vm

import android.app.Application
import android.text.TextUtils
import androidx.lifecycle.MutableLiveData
import client.comm.baoding.ui.viewmodel.MiddleVm
import client.comm.commlib.network.data.JsonResult
import client.comm.commlib.network.data.Ret
import client.comm.commlib.toast.toast

class UpdateUserInfoViewModel(app: Application) : MiddleVm(app) {

    val name = MutableLiveData<String>("")
    val isShowing = MutableLiveData<Boolean>(false)
    val call = MutableLiveData<JsonResult<Ret>>()

    fun commit() {
        if (TextUtils.isEmpty(name.value)) {
            toast("用户名不得为空")
            return
        }

        hold({
            server.reset_username(
                name.value!!
            )
        }, {
            isShowing.value = true
        }, {
            call.value = it
        }, {
        }, {
            isShowing.value = false
        })
    }


}